package com.lzq.mq.common.enums;

/**
 * broker注册角色枚举
 */
public enum BrokerRegistryRoleEnum {

    MASTER("master"),
    SLAVE("slave"),
    SINGLE("single"),
    ;

    String code;

    BrokerRegistryRoleEnum(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    /**
     * 判断某个code是否是枚举中元素, 是则返回元素
     */
    public static BrokerRegistryRoleEnum of(String code) {
        for (BrokerRegistryRoleEnum brokerRegistryEnum : BrokerRegistryRoleEnum.values()) {
            if (brokerRegistryEnum.getCode().equals(code)) {
                return brokerRegistryEnum;
            }
        }
        return null;
    }
}
